import http from "@/api";
import { System, ResPage } from "@/api/interface/index";
import qs from "qs";

//权限资源树
export const getSystemResourceTree = (params: { isMenu: string }) => {
  return http.post<System.SystemResourceTree>(`systemResource/tree`, qs.stringify(params));
};

//编辑权限资源
export const saveSystemResource = (params: System.SaveSystemResource) => {
  return http.post(`systemResource/save`, qs.stringify(params));
};

//删除权限资源
export const delSystemResource = (params: { ids: number }) => {
  return http.post(`systemResource/del`, qs.stringify(params));
};

//角色列表
export const getAdminRoleList = (params: System.AdminRoleParams) => {
  return http.post<ResPage<System.AdminRole>>(`adminRole/list`, qs.stringify(params));
};
//切换角色状态
export const changeAdminRoleStatus = (params: { id: number; status: number }) => {
  return http.post(`adminRole/status`, qs.stringify(params));
};
//角色详情
export const getAdminRoleInfo = (params: { id: number }) => {
  return http.post<System.AdminRoleInfo>(`adminRole/info`, qs.stringify(params));
};
//编辑角色
export const saveAdminRole = (params: System.AdminRoleInfo) => {
  delete params.rightsListArr;
  return http.post(`adminRole/save`, qs.stringify(params));
};
//删除角色
export const delAdminRole = (params: { ids: number }) => {
  return http.post(`adminRole/del`, qs.stringify(params));
};

//管理员列表
export const getAdminUserList = (params: System.AdminUserParams) => {
  return http.post<ResPage<System.AdminUser>>(`adminUser/list`, qs.stringify(params));
};
//切换管理员状态
export const changeAdminUserStatus = (params: { id: number; status: number }) => {
  return http.post(`adminUser/status`, qs.stringify(params));
};
//编辑管理员
export const saveAdminUser = (params: System.AdminUser) => {
  return http.post(`adminUser/save`, qs.stringify(params));
};
//删除管理员
export const delAdminUser = (params: { ids: number }) => {
  return http.post(`adminUser/del`, qs.stringify(params));
};
//重制管理员密码
export const resetAdminUserPassword = (params: { ids: number; password: string }) => {
  return http.post(`adminUser/reset`, qs.stringify(params));
};
